# coding: utf-8

import web
from urls import urls

web.config.debug = False
web.config.session_parameters['timeout'] = 86400 * 7
web.config.session_parameters['ignore_expiry'] = True
web.config.session_parameters['secret_key'] = 'adhfgdkfjhgdfjkertertsdhf'


class MyApplication(web.application):
    def run(self, port=8080, *middleware):
        func = self.wsgifunc(*middleware)
        return web.httpserver.runsimple(func, ('0.0.0.0', port))


app = MyApplication(urls, globals())

session = web.session.Session(app, web.session.DiskStore('sitedata/sessions'))
def session_hook():
    web.ctx.session = session
app.add_processor(web.loadhook(session_hook))


if __name__ == '__main__':
    app.run(9898)
